﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Project_KhuyenMaiVang.DAO;
using Project_KhuyenMaiVang.Models;

namespace Project_KhuyenMaiVang.Controllers
{
    public class TinKhuyenMaiController : Controller
    {
        //
        // GET: /TinKhuyenMai/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Edit(int id)
        {
            TinKhuyenMaiDAO tinKhuyenMaiDAO = new TinKhuyenMaiDAO();
            TinKhuyenMaiDTO tinKhuyenMaiInfo = tinKhuyenMaiDAO.getDetailOfSaleOffNews(id);
            return View(tinKhuyenMaiInfo);
        }
        [HttpPost]
        public ActionResult Edit(TinKhuyenMaiDTO tinKhuyenMai)
        {
            TinKhuyenMaiDAO tinKhuyenMaiDAO = new TinKhuyenMaiDAO();
            tinKhuyenMaiDAO.update(tinKhuyenMai);
            return RedirectToAction("QuanLyTinKhuyenMai", "Admin");
        }

        public ActionResult Delete(int id)
        {
            TinKhuyenMaiDAO tinKhuyenMaiDAO = new TinKhuyenMaiDAO();
            tinKhuyenMaiDAO.delete(id);
            return RedirectToAction("QuanLyTinKhuyenMai", "Admin");
        }
    }
}
